Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
web-encoding
Advanced tools
TextEncoder and TextDecoder APIs from Encoding Standard APIs in a universal package
The web-encoding package provides a polyfill for the TextEncoder and TextDecoder interfaces, which are part of the Encoding Living Standard. These interfaces allow for high-performance encoding and decoding of text in various character encodings, primarily UTF-8.
Text Encoding
This feature allows you to encode a JavaScript string into a Uint8Array of bytes using UTF-8 encoding. It is useful for preparing text data for network transmission or storage.
const { TextEncoder } = require('web-encoding');
const encoder = new TextEncoder();
const encoded = encoder.encode('Hello, world!');
console.log(encoded);
Text Decoding
This feature enables decoding of a Uint8Array of bytes into a JavaScript string using UTF-8 or other supported character encodings. It is essential for reading text data received from a network or read from binary storage.
const { TextDecoder } = require('web-encoding');
const decoder = new TextDecoder('utf-8');
const decoded = decoder.decode(new Uint8Array([72, 101, 108, 108, 111]));
console.log(decoded);
The text-encoding package also provides TextEncoder and TextDecoder polyfills. It supports a wider range of encodings than web-encoding, making it suitable for applications that need to handle various character sets beyond UTF-8.
Similar to web-encoding, fast-text-encoding offers TextEncoder and TextDecoder implementations. It focuses on performance optimizations for UTF-8 encoding and decoding, making it a good choice for performance-critical applications that primarily deal with UTF-8 data.
This package provides TextEncoder and TextDecoder Encoding Standard
APIs in a universal package. In the browsers it just exposes existing globals,
in nodejs it exposes globals in newer node versions and ones from util
module
in older versions, and in the React Native environments it exposes these from
the @zxing/text-encoding
polyfill (installed as an optional dependency).
Package also works as ES module and CommonJS module.
import { TextEncoder, TextDecoder } from "web-encoding"
npm install web-encoding
FAQs
TextEncoder and TextDecoder APIs from Encoding Standard APIs in a universal package
The npm package web-encoding receives a total of 1,332,718 weekly downloads. As such, web-encoding popularity was classified as popular.
We found that web-encoding demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.